%%%-----------------------------------
%%% @Module  : pt_24
%%% @Author  : 
%%% @Created : 
%%% @Description: 
%%%-----------------------------------
-module(pt_24).
-export([read/2, write/2]).
-include("common.hrl").
-include("proto_24_sign.hrl").

%%
%%客户端 -> 服务端 ----------------------------
%%

%% 24000 请求玩家签到数据
read(24000, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_get_sign_data, Bin), 
    #c2s_get_sign_data{player_id = PlayerId} = ClientData,
    {ok, [PlayerId]};

%% 24001 玩家签到
read(24001, Bin) ->
    {ClientData, _} = proto_read:unpack(c2s_sign, Bin),    
    #c2s_sign{player_id = PlayerId} = ClientData,
    {ok, [PlayerId]};

read(_Cmd, _R) ->
    ?ERROR_MSG("~s pt_23 reading cmd_[~p], Data:~p~n",[misc:time_format(game_timer:now()), _Cmd, _R]),
    {error, no_match}.

%%
%%服务端 -> 客户端 ------------------------------------
%%
%% 24000 请求玩家签到数据
write(24000, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_get_sign_data, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(24000, ServerData)};

%% 24001 玩家签到
write(24001, [Seq, RecordData]) ->
    MsgPack = proto_write:pack(s2c_sign, RecordData),
    ServerData = <<Seq:32, MsgPack/binary>>,
    {ok, pt:pack(24001, ServerData)};

write(Cmd, _R) ->
    ?ERROR_MSG("~s pt_23 writting cmd_[~p], Data:~p~n",[misc:time_format(game_timer:now()), Cmd, _R]),
    {ok, pt:pack(0, <<>>)}.
